package shin.test.web.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import com.google.appengine.api.users.User;
import com.google.appengine.api.users.UserService;
import com.google.appengine.api.users.UserServiceFactory;

public class MyInteceptor extends HandlerInterceptorAdapter {
	public boolean preHandle(HttpServletRequest request,
			HttpServletResponse response, Object o) throws Exception {
		UserService userService = UserServiceFactory.getUserService();
        User user = userService.getCurrentUser();
        request.setAttribute("user", user);   
        request.setAttribute("logoutUrl", userService.createLogoutURL(request.getRequestURI()));
        request.setAttribute("loginUrl", userService.createLoginURL(request.getRequestURI()));
        return true;
	}

}
